<?php
class Usuario extends AppModel {
	var $name = 'Usuario';
	var $useDbConfig = 'seguridad';
	var $actsAs = array('Acl' => array('type' => 'requester'));

	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $belongsTo = array(
		'Persona' => array(
			'className' => 'Persona',
			'foreignKey' => 'persona_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Rol' => array(
			'className' => 'Rol',
			'foreignKey' => 'rol_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
	);

	function parentNode() {
		    if (!$this->id && empty($this->data)) {
		        return null;
		    }
		    if (isset($this->data['Usuario']['rol_id'])) {
				$rolId = $this->data['Usuario']['rol_id'];
		    } else {
		    	$rolId = $this->field('rol_id');
		    }
		    if (!$rolId) {
			return null;
		    } else {
		        return array('Rol' => array('id' => $rolId));
		    }
	}
}
?>